<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- react 分为 react-dom页面开发和  react--native app开发 所有功能要拆分 -->
    <!-- react核心包,提供了操作react的所有必要功能, 但是不提供Dom操作的相关功能, web和app都使用 -->
    <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
    <!-- reactDOM, 提供支持操作dom的相关功能 -->
    <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
    <!-- 添加后可直接使用jsx语法 -->
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>

<body>
    <div id="root">

    </div>
    <script type="text/babel">
        const msg = 'hello world';
        const reactRoot = ReactDOM.createRoot(document.getElementById('root'))
        const list = [
            { id: 10, title: '哈哈哈', price: 343.343 },
            { id: 11, title: '哈哈哈', price: 343.343 },
            { id: 12, title: '哈哈哈', price: 343.347 },
            { id: 13, title: '哈哈哈', price: 343.343 },
            { id: 14, title: '哈哈哈', price: 343.349 },
        ]

        // 函数式组件
        function Welcome(props) {
            return <h1>Hello, {props.name}</h1>;
        }

        const vdom = <div>
            <ul>{
                list.map((item, key) => {
                    return <li key={item.id}> id={item.id}, title={item.title}, price={item.price.toFixed(2)}</li>
                })
            }</ul>
        </div>
        const list1 = <ul>{
            Array(10).fill(null).map((item, key) =>
                <li key={key}>{key}</li>
            )
        }</ul>
        reactRoot.render(
            <React.Fragment>
                <Welcome name="111232"></Welcome>
                {list1}
                {vdom}
            </React.Fragment>
        )
    </script>
</body>

</html>